package com.example.littlepainter.data

import androidx.lifecycle.LiveData
import com.example.littlepainter.db.Picture
import com.example.littlepainter.db.PictureDatabase

/**
 * 中转站 统一的数据存取方法
 */
class Repository {
    private val dao = PictureDatabase.db().pictureDao()
    suspend fun addPicture(picture: Picture){
            dao.insertPicture(picture)
    }
    fun loadDatas(): LiveData<List<Picture>> {
        return dao.queryPictures()
    }
    suspend fun deleteAll(pictures: List<Picture>){
        dao.deleteAll(pictures)
    }
    suspend fun deletePicture(picture: Picture){
        dao.deletePicture(picture)
    }
    suspend fun updatePicture(picture: Picture){
        dao.updatePicture(picture)
    }
}
